<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品规格列表')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse hidden">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>产品id：</label>
                            <input hidden="hidden" type="text" name="productId" th:value="${productId}"/>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="applet:product:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="applet:product:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">

    let editFlag = [[${@permission.hasPermi('applet:product:edit')}]];
    let removeFlag = [[${@permission.hasPermi('applet:product:remove')}]];
    let statusDatas = [[${@dict.getType('applet_status')}]];

    let prefix = ctx + "applet/productSpecifications";

    $(function () {
        let options = {
            url: prefix + "/list",
            createUrl: prefix + "/add/" + [[${productId}]],
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "产品规格",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '产品规格id',
                    visible: false
                },
                {
                    field: 'specificationsName',
                    title: '规格名称'
                },
                {
                    field: 'price',
                    title: '价格'
                },
                {
                    field: 'unit',
                    title: '单位'
                },
                {
                    field: 'stock',
                    title: '库存'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'defaultFlag',
                    title: '是否默认'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        let actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>